<?php

class OrderAction extends  CommonAction{

	function  index(){

		

					import('ORG.Util.Page');// 导入分页类

	               $count = M('Order')->count();// 查询满足要求的总记录数 $map表示查询条件

                   $Page = new Page($count,C('PAGESIZE'));// 实例化分页类 传入总记录数

                   $this->page = $Page->show();// 分页显示输出

	               $temp = M('Order')->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

	               $list = array();

                    foreach ($temp as $v){

                    	$v['title']=M('Product')->where("id=".$v['product_id'])->getField('title');

                    	$list[] =$v;

                    }  

                  

                    $this->assign("list",$list); 

                   $this->display();

	              

	}


	function view(){
          $this->li =M('Order')->where("id=".$_GET['id'])->find();
          $product_id = $this->li['product_id'];
          $title=M('Product')->where("id=".$product_id)->getField('title');
          $this->assign("title",$title);
          $this->display();
	}

}

?>